<!--
 * @Description: 项目经理动态信息
 * @Author: wind-lc
 * @version: 1.0
 * @Date: 2021-09-26 16:15:53
 * @LastEditTime: 2022-11-25 16:08:14
 * @FilePath: \cscec-pms-admin\src\views\project\projectDynamicInformation\projectManager.vue
-->
<template>
  <base-breadcrumb
    :title="$route.meta.title"
    :breadcrumb="!isAudit"
  >
    <a-card>
      <a-tabs v-model="key">
        <a-tab-pane
          key="1"
          tab="项目动态履约信息"
        >
          <PerformanceInformation
            ref="performanceInformation"
            :submiting.sync="submiting"
            :projectId.sync="projectId"
          />
          <div class="pub-next-btn">
            <a-button
              type="primary"
              @click="key = '2'"
            > 下一步 </a-button>
          </div>
        </a-tab-pane>
        <a-tab-pane
          key="2"
          tab="资源配置"
          force-render
        >
          <ResourceAllocation :projectId.sync="projectId" />
          <div class="pub-next-btn">
            <a-button
              type="primary"
              @click="key = '1'"
            > 上一步 </a-button>
          </div>
        </a-tab-pane>
      </a-tabs>
    </a-card>
    <div class="page-btn-right-top">
      <template v-if="$route.query.pageType !== 'detail' && !$route.query.detailUrl">
        <a-button
          v-if="!isAudit"
          type="primary"
          :loading="submiting"
          @click="handleSaveDrafts"
        > 保存草稿 </a-button>
        <a-button
          v-if="!isAudit"
          type="primary"
          class="ml20"
          :loading="submiting"
          @click="handleSubmit"
        > 提交 </a-button>
      </template>
      <a-button
        type="primary"
        class="ml20"
        @click="$close"
      > 关闭 </a-button>
    </div>
  </base-breadcrumb>
</template>
<script>
import PerformanceInformation from './components/PerformanceInformation'
import ResourceAllocation from './components/ResourceAllocation'
export default {
  name: 'ProjectManager',
  props: {
    isAudit: {
      type: Boolean,
      default: false
    }
  },
  components: {
    PerformanceInformation,
    ResourceAllocation
  },
  data() {
    return {
      // 标签页选中
      key: '1',
      // 是否提交状态
      submiting: false,
      projectId: ''
    }
  },
  methods: {
    /**
     * @description: 提交
     * @param {void}
     * @return {void}
     */
    handleSubmit() {
      this.$refs.performanceInformation.submit()
    },
    /**
     * @description: 保存草稿
     * @param {void}
     * @return {void}
     */
    handleSaveDrafts() {
      this.$refs.performanceInformation.saveDrafts()
    }
  },
  beforeRouteEnter(to, from, next) {
    if (to.path === '/project/projectDynamicInformation/projectManager') {
      to.query.pageType === 'update' ? (to.meta.title = '项目动态信息编辑') : (to.meta.title = '项目动态信息查看')
    }
    next()
  }
}
</script>
<style lang="less" scoped>
</style>

